﻿#include "userregistrationform.h"
#include "ui_userregistrationform.h"

UserRegistrationForm::UserRegistrationForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::UserRegistrationForm)
{
    ui->setupUi(this);
    MySql my_op;
    QSqlDatabase db = my_op.db;
}

UserRegistrationForm::~UserRegistrationForm()
{
    delete ui;
}

void UserRegistrationForm::on_OK_clicked()
{

    QString usrName = ui->UserName->text();
    QString passWd = ui->PassWd->text();
    QString passWd2 = ui->PassWd_2->text();
    if (passWd == passWd2)
    {
        User usr;
        usr.usrName = usrName;
        usr.passWd = passWd;
        UsrInfo usrOp;
        usrOp.InsertUsrInfoDataToDb(db,usr);
        this->close();

    }
    else
    {
         QMessageBox::warning(0,"Error",QString::fromLocal8Bit("两次输入的密码不一致"));
    }

    //1.根据用户名查询，当前的用户是否已经注册？如果是，则提示已注册
                   //2.比较两次输入的密码是否一致，如果不一致给出提醒；
                   //3.如果条件均成立，则将注册信息写入数据库，并提示注册成功。

}

void UserRegistrationForm::on_Cancel_clicked()
{
    this->close();
}
